/**
Copyright 2022 ShenZhen Xiaoniu New Energy Inc. All Rights Reserved.
Author: saico@mosf.cn
**/

if (typeof(Array.prototype.contains) === "undefined") {
    Array.prototype.contains = function (obj) {
        let i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
            }
        }
        return false;
    };
}

export default {

    // OTAS3BUCKET: 'afr-ota-hk',
    OTAS3BUCKET: 'afr-ota-kr',
    // OTAS3BUCKET: 'afr-ota-eu',
    
    APIVERSION: '1.0.0',
    DD: 'YYYY-MM-DD',
    SF: 'YYYYMMDDHHmmss',
    TF: 'YYYY-MM-DD HH:mm:ss',
    D2: 'MM-DD_HH:mm:ss',
    ST: 'HH:mm:ss',
    MQTTWORK: 'xniot/work/',
    MQTTDTOS: 'xniot/dtos/',
    
    SQSURLTEMPLATE: 'https://sqs.REGION.amazonaws.com/ACCOUNTID/espQUEUE',

    POLICY_DOCUMENT: 
`{
  "Version": "2012-10-17",
  "Statement": [
  {
      "Effect": "Allow",
      "Action": "iot:Connect",
      "Resource": "arn:aws:iot:REGION:ACCOUNTID:client/$\{iot:Connection.Thing.ThingName\}"
  },
  {
      "Effect": "Allow",
      "Action": ["iot:Receive","iot:Publish"],
      "Resource":[
          "arn:aws:iot:REGION:ACCOUNTID:topic/$aws/things/$\{iot:Connection.Thing.ThingName\}/shadow/*",
          "arn:aws:iot:REGION:ACCOUNTID:topic/$aws/things/$\{iot:Connection.Thing.ThingName\}/jobs/*",
          "arn:aws:iot:REGION:ACCOUNTID:topic/$aws/things/$\{iot:Connection.Thing.ThingName\}/streams/*",
          "arn:aws:iot:REGION:ACCOUNTID:topic/xniot/dtos/$\{iot:Connection.Thing.ThingName\}",
          "arn:aws:iot:REGION:ACCOUNTID:topic/xniot/work/$\{iot:Connection.Thing.ThingName\}"
      ]
  },
  {
      "Effect": "Allow",
      "Action": "iot:Subscribe",
      "Resource":[
          "arn:aws:iot:REGION:ACCOUNTID:topicfilter/$aws/things/$\{iot:Connection.Thing.ThingName\}/shadow/*",
          "arn:aws:iot:REGION:ACCOUNTID:topicfilter/$aws/things/$\{iot:Connection.Thing.ThingName\}/jobs/*",
          "arn:aws:iot:REGION:ACCOUNTID:topicfilter/$aws/things/$\{iot:Connection.Thing.ThingName\}/streams/*",
          "arn:aws:iot:REGION:ACCOUNTID:topicfilter/xniot/dtos/$\{iot:Connection.Thing.ThingName\}",
          "arn:aws:iot:REGION:ACCOUNTID:topicfilter/xniot/work/$\{iot:Connection.Thing.ThingName\}"
      ]
  },
  {
      "Effect": "Allow",
      "Action": "iot:UpdateThingShadow",
      "Resource": "arn:aws:iot:REGION:ACCOUNTID:thing/$aws/things/$\{iot:Connection.Thing.ThingName\}/shadow/*"
  }
  ]
}`,

};
